package com.truthbean.jutils.web.utils;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;

public class ResponseUtil {

    public static void print(HttpServletResponse response, Object o) {
        response.setContentType("application/json;charset=utf-8");
        PrintWriter out = null;
        try {
            out = response.getWriter();
            out.println(new Gson().toJson(o));
            response.setHeader("pragma", " no-cache");
            response.setHeader("cache-control", " no-cache");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (out != null) {
                out.flush();
                out.close();
            }
        }
    }

}
